Skip to content

fix(cli): refuse blank --port/--host/--latency/--journal-max/--fixture-counts-max values - #644

Merged
jpr5 merged 3 commits into
CopilotKit:mainfrom
HeyImBG:fix/cli-blank-option-values
Dec 1, 2026
Merged

jpr5 merged 3 commits into
CopilotKit:mainfrom
HeyImBG:fix/cli-blank-option-values

Conversation

@HeyImBG

@HeyImBG HeyImBG commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

What was wrong

llmock (src/cli.ts) reads option values with Number(value), and Number("") is 0. So an empty value (for example from an unset shell variable) was accepted silently:

  • --journal-max "" and --fixture-counts-max "" became 0 (unlimited),
  • --port "" opened a random port,
  • --latency "" became 0,
  • --host "" was passed to listen() as "", which Node binds to all interfaces (::) instead of the documented 127.0.0.1 default. Low severity: it only happens when a blank value is passed explicitly.

aimock-cli.ts already handles this class of input (4e3d589, "refuse blank option values"); cli.ts did not get the same check.

What changed

After the help check, cli.ts exits with code 1 and Error: --X requires a non-empty value. (plus help) when one of these 5 options is empty or whitespace. The check and message match aimock-cli.ts.

How it was tested

  • main + the new tests: cli.test.ts 10 failed / 47 passed.
  • With the fix: cli.test.ts 57/57; npm run build and npm run lint pass; prettier clean.
  • npm run typecheck fails with the same 8 errors on a clean main (openapi-catalog.test.ts, vector-stores.test.ts), unrelated to this change.
  • The full npm test run did not finish in my environment, so it is not verified here.

AI disclosure

This change was found, written and tested with Claude Code (Anthropic). I'm responsible for it and happy to rework anything.


🤖 Generated with Claude Code

https://claude.ai/code/session_01A3CSud8Qn852zfCa7YofiN

…e-counts-max values

Number("") is 0, so a blank --port bound a random port and a blank
--journal-max / --fixture-counts-max meant unbounded. A blank --host reached
listen() as "", which binds every interface instead of 127.0.0.1.
aimock-cli.ts already refuses blank values (4e3d589); mirror it in cli.ts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A3CSud8Qn852zfCa7YofiN
@pkg-pr-new

pkg-pr-new Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@644

commit: da2bd7e

@jpr5
jpr5 merged commit 0d9b74e into CopilotKit:main Dec 1, 2026
30 checks passed
@jpr5

jpr5 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Merged, thanks! Added a changelog line calling out that blank values now exit 1 instead of starting.

@jpr5 jpr5 mentioned this pull request Dec 1, 2026
jpr5 added a commit that referenced this pull request Dec 1, 2026
## [1.49.0] - 2026-11-30

### Added

- Replayable seeded chaos: `--chaos-seed`/`x-aimock-chaos-seed`; journal `chaosOrigin` (#618, #653)
- Recorder writes `requestHash`; stale replays get journal `staleFixture` and a warning (#640, #651)

### Changed

- `aimock-pytest` 0.7.4 defaults to `@copilotkit/aimock` 1.49.0

### Fixed

- Split image turns match `userMessage` on Anthropic, Gemini (+Live), Bedrock, Cohere (#643, #648)
- `llmock` now errors on blank `--port`/`--host`/`--latency`/... values instead of starting (#644)
jpr5 added a commit that referenced this pull request Dec 1, 2026
**Merging this publishes @copilotkit/aimock 1.49.0 to npm and
aimock-pytest 0.7.4 to PyPI.**

## [1.49.0] - 2026-11-30

### Added

- Replayable seeded chaos: `--chaos-seed`/`x-aimock-chaos-seed`; journal
`chaosOrigin` (#618, #653)
- Recorder writes `requestHash`; stale replays get journal
`staleFixture` and a warning (#640, #651)

### Changed

- `aimock-pytest` 0.7.4 defaults to `@copilotkit/aimock` 1.49.0

### Fixed

- Split image turns match `userMessage` on Anthropic, Gemini (+Live),
Bedrock, Cohere (#643, #648)
- `llmock` now errors on blank `--port`/`--host`/`--latency`/... values
instead of starting (#644)

Two new features, so this is a minor release.

## Version carriers (from `git grep -F 1.48.1`)

Bumped to 1.49.0:
- `package.json` version
- `charts/aimock/Chart.yaml` appVersion
- `.claude-plugin/plugin.json` version
- `.claude-plugin/marketplace.json` source version (`^1.49.0`)
- `docs/index.html` banner
- `packages/aimock-pytest/README.md` `--aimock-version` default
- `packages/aimock-pytest/src/aimock_pytest/_version.py`
`AIMOCK_VERSION`

Also bumped: `packages/aimock-pytest/pyproject.toml` 0.7.3 → 0.7.4,
because the pin moved (same pattern as #628).

Left as is: the `## [1.48.1]` CHANGELOG section.

## CHANGELOG edits

- `## [Unreleased]` becomes `## [1.49.0] - 2026-11-30`.
- Seven bullets became four, plus the aimock-pytest `Changed` line: the
two #618 lines are one, #643 and #648 are one, and #651 joins the
stale-fixture line.
- The stale-fixture line now references PR #640 instead of issue #638.

## Docs

- `docs/record-replay`: the `llmock` flag table gets `--chaos-seed` and
`--chaos-keys-max`, and a note that blank
`--port`/`--host`/`--latency`/`--journal-max`/`--fixture-counts-max`
values are a usage error (#644).
- `docs/fixtures`: the "last user message" rule now says a trailing
image-only user message is skipped (#643, #648).
- `README.md`: the Record & Replay line mentions stale-fixture flagging.
Seeded chaos was already in the Chaos Testing line.

Already covered, left alone: `docs/chaos-testing` (seeds,
`x-aimock-chaos-seed`, `chaosOrigin`, `--chaos-keys-max`) and the Stale
Fixtures section of `docs/record-replay` (`requestHash`, `staleFixture`,
the `STALE FIXTURE` warning, `requestTransform`). The `package.json`
description already matches the README subtitle.

## Local checks
- `pnpm install --frozen-lockfile`, `format:check`, `lint`, `typecheck`,
`build`: pass
- `api:report`: 14 entries, 0 failed, no report change
- `vitest run`: 503 files, 20,346 passed, 11 skipped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants